package com.yricky.memoria.activity

import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.yricky.memoria.R
import com.yricky.memoria.utils.RStr
import com.yricky.memoria.utils.ws

/**
 * @author Yricky
 * @date 2021/12/3
 */
class ProcessTextActivity:BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val text = when(intent.action){
            Intent.ACTION_PROCESS_TEXT ->intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT).toString()
            else->"${intent.action}"
        }
        setContent {
            Column(modifier = Modifier.padding(8.dp),){
                Text(text = text)
                Button(onClick = {
                    ws.addTextItem(text)
                    finish()
                }) {
                    Text(text = RStr.from(R.string.ok))
                }
            }

        }
    }
}